<?php
include("./config/session.php");
include("./class/template.inc");
include("./config/config.inc.php");
include("./config/QuickMySQL.php");

class CIndex extends PageBase
{
	public $mysql  = null;
	/*加载页面*/
	function OnPageLoad(){
		$user = $_SESSION['user'];
		/*加载页面文件*/
		$tpl = new Template("./ui/");
		$tpl->set_file("main", "index.html");
		/*设置顶部参数*/
		$tpl->set_var("UserName", $_SESSION['user']);
		/*左侧菜单栏数据*/
		$menu = array( "客户管理" => array(  )
				, "邮件群发" => array( array("title" => "新建发送任务", "url" => "sendemail-add.php", "console" => true)
					, array("title" => "邮件群发列表", "url" => "sendemail-group.php", "console" => true)
					, array("title" => "到期提醒列表", "url" => "sendemail-last.php", "console" => true)
					, array("title" => "邮件用户列表", "url" => "email.php", "console" => true)
					)
				, "短信群发" => array()
				, "彩信群发" => array()
				, "系统设置" => array()
			);
		/*从数据库获取用户列表*/
		$this->mysql = new QuickMySQL();
		$res = $this->mysql->Query("select sname,url from t_list_user");
		while( $row = mysql_fetch_row($res) ){
			array_push($menu["客户管理"]
				, array("title" => $row[0], "url" => $row[1], "console" => true));
		}
		mysql_free_result($res);
		/*构造右侧菜单*/
		$tpl->set_block("main", "menulist", "menu-lists");
		$tpl->set_block("menulist", "menuitem", "menu-itmes");
		foreach( $menu as $menutype=>$menuitems){
			$tpl->set_var("menu-itmes", "");
			foreach( $menuitems as $menuitem){
				$tpl->set_var("showtitle", $menuitem["title"]);
				$tpl->set_var("linkurl", $menuitem["url"]);
				$tpl->set_var("console", $menuitem["console"]?"true":"false");
				$tpl->parse("menu-itmes", "menuitem", true);
			}
			$tpl->set_var("menutype", $menutype);
			$tpl->parse("menu-lists", "menulist", true);
		}
		
		/*输出结果*/
		$tpl->parse("mains", "main");
		$tpl->p("mains");
	}
}

$cc = new CIndex();
?>
